//
//  UImage.swift
//  Weibo
//
//  Created by 贵永冬 on 16/7/14.
//  Copyright © 2016年 贵永冬. All rights reserved.
//

import UIKit

extension UIImage {
    /**
     原图渲染
     - parameter imageName: 图片名字
     */
    static func imageWithOriginal(imageName : String) -> UIImage {
        let image = UIImage(named: imageName)
        if image == nil {
            return UIImage()
        }
        let newImage = image?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        if let tempImage = newImage {
            return tempImage
        }else {
            return UIImage()
        }
    }
    /**
     原图渲染 并且拉伸图片 只拉伸图片的中心点
     - parameter imageName: 图片名
     */
    static func resizedImage(imageName : String) -> UIImage {
        let image = UIImage.imageWithOriginal(imageName)
        return image.stretchableImageWithLeftCapWidth(Int(image.size.width * 0.5), topCapHeight: Int(image.size.height * 0.5))
        
    }
}

